package com.zjcode.cdcer.config;

import com.chinatechstar.component.commons.config.CommonResourceServerConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;

/**
 * @ClassName:ResourceServerConfig
 * @功能：
 * @author：wlei
 * @日期：2021/1/26-1:42 下午
 **/
@Configuration
@EnableResourceServer
public class ResourceServerConfig extends CommonResourceServerConfig {

    @Autowired
    public ResourceServerConfig(ResourceServerProperties sso) {
        super(sso);
    }

    /**
     * 配置拦截路径的安全规则
     */
    @Override
    public void configure(HttpSecurity httpSecurity) throws Exception {
        httpSecurity
            .authorizeRequests()
            .antMatchers("/v1/**", "/actuator/**")
            .permitAll()
            .anyRequest()
            .authenticated();
    }
}

